/*
 * @Author: wupeiwen <javapeiwen2010@gmail.com>
 * @Date: 2022-03-21 11:34:22
 * @LastEditors: wupeiwen <javapeiwen2010@gmail.com>
 * @LastEditTime: 2023-03-21 15:35:34
 * @FilePath: /tea-garden-web/vue.config.js
 * @Description: vue-cli配置
 */
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig(() => {
  const option = {
    transpileDependencies: true,
    publicPath: '/',
    outputDir: './dist',
    lintOnSave: process.env.NODE_ENV !== 'production',
    runtimeCompiler: false,
    productionSourceMap: true,
    pwa: {
      name: process.env.VUE_APP_SYSTEM_SHORTNAME,
      manifestOptions: {
        name: process.env.VUE_APP_SYSTEM_NAME,
        short_name: process.env.VUE_APP_SYSTEM_SHORTNAME,
        theme_color: '#ffffff',
        background_color: '#ffffff',
        display: 'fullscreen',
        orientation: 'landscape-primary'
      }
    },
    devServer: {
      open: false,
      host: '0.0.0.0',
      port: 8080,
      proxy: {
        '^/api/weather': {
          target: 'https://weather.cma.cn', // 目标 API 地址
          changeOrigin: true, // 是否允许跨域请求
          pathRewrite: { '^/api/weather': '' }
        },
        '^/TeaGarden': {
          target: 'http://dev.yunqi-tech.net:10500', // 目标 API 地址
          changeOrigin: true, // 是否允许跨域请求
          pathRewrite: { '^/TeaGarden': '' }
        }
      }
    }
  }
  // 数据接口代理
  // option.devServer.proxy[`${process.env.VUE_APP_LOCATION}`] = {
  //   target: process.env.VUE_APP_TARGET,
  //   changeOrigin: true
  // }
  return option
})
